home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / graphics / scrfe100.zip / FONTS_N.ASM < prev    next >
Assembly Source File  |  1993-02-27  |  6KB  |  454 lines

  1. _CODE SEGMENT BYTE PUBLIC 'CODE'
  2. ASSUME CS:_CODE
  3. ; This is the NEAR implementation of Fontools in C-callable format.
  4. ; Pointers are FAR, so if you are using the tiny or small memory model,
  5. ; (instead of compact) switch the appropriate portions of the code that
  6. ; are marked with *****. See the C header file for information concerning
  7. ; this.
  8.  
  9. false equ 0
  10. true equ 1
  11. lines200 equ 0
  12. lines350 equ 1
  13. lines400 equ 2
  14. parama equ [bp+4]
  15.  
  16. vseg dw 0b800h
  17. linesperchar db 13 ; points - 1
  18. vga db false
  19. ega db false
  20. vedone db false
  21.  
  22. fontheader db '@JLSFF',1
  23.  
  24. cmpegafalse proc near
  25. cmp byte ptr vedone,true
  26. je cef
  27. call detega
  28. cef:
  29. cmp byte ptr ega,false
  30. ret
  31. cmpegafalse endp
  32.  
  33. cmpvgafalse proc near
  34. cmp byte ptr vedone,true
  35. je cvf
  36. call detega
  37. cvf:
  38. cmp byte ptr vga,false
  39. ret
  40. cmpvgafalse endp
  41.  
  42. PUBLIC _SEQUENCEFONTS
  43.  
  44. _sequencefonts proc near
  45. call cmpegafalse
  46. je nosequence
  47. push ax
  48. push dx
  49. mov ax,0704h
  50. mov dx,03c4h
  51. out dx,ax
  52. mov dx,03ceh
  53. mov ax,0204h
  54. out dx,ax
  55. mov ax,5
  56. out dx,ax
  57. mov ax,0406h
  58. out dx,ax
  59. mov ax,0402h
  60. mov dx,03c4h
  61. out dx,ax
  62. pop dx
  63. pop ax
  64. nosequence:
  65. ret
  66. _sequencefonts endp
  67.  
  68. PUBLIC _DESEQUENCEFONTS
  69.  
  70. _desequencefonts proc near
  71. call cmpegafalse
  72. je nodesequence
  73. push ax
  74. push dx
  75. mov dx,03c4h
  76. mov ax,0302h
  77. out dx,ax
  78. mov ax,0304h
  79. out dx,ax
  80. mov dx,03ceh
  81. mov ax,4
  82. out dx,ax
  83. mov ax,01005h
  84. out dx,ax
  85. mov ax,0e06h
  86. cmp vseg,0b000h
  87. jne d1
  88. mov ax,0606h
  89. d1:
  90. out dx,ax
  91. pop dx
  92. pop ax
  93. nodesequence:
  94. ret
  95. _desequencefonts endp
  96.  
  97. PUBLIC _SETSCANLINES
  98.  
  99. _setscanlines proc near ; number of scanlines as parameter, al
  100.  ; 0=200 lines  1 = 350 lines  2 = 400 lines
  101. push bp
  102. mov bp,sp
  103. jmp ssl
  104. scnlns db 0
  105. ssl:
  106. push ax
  107. push bx
  108. push cx
  109. mov al,parama
  110. mov scnlns,al
  111. cmp al,2
  112. ja nossl
  113. call cmpvgafalse
  114. je nossl
  115. mov al,scnlns
  116. mov ah,012h
  117. mov bx,030h
  118. int 010h
  119. mov ax,083h   ; set mode with no video memory clearing
  120. cmp vseg,0b000h
  121. jne s1
  122. mov ax,087h
  123. s1:
  124. int 010h
  125. mov cx,0c0dh
  126. mov al,scnlns
  127. cmp al,0
  128. jne s2
  129. mov cx,0708h
  130. s2:
  131. mov ax,0100h
  132. int 010h
  133. nossl:
  134. pop cx
  135. pop bx
  136. pop ax
  137. pop bp
  138. ret
  139. _setscanlines endp
  140.  
  141. setlinesperchar proc near
  142. call cmpegafalse
  143. je noslpc
  144. push ax
  145. push bx
  146. push cx
  147. push dx
  148. mov ax,01100h
  149. mov bh,linesperchar
  150. xor bl,bl
  151. xor cx,cx
  152. xor dx,dx
  153. int 010h
  154. pop dx
  155. pop cx
  156. pop bx
  157. pop ax
  158. noslpc:
  159. ret
  160. setlinesperchar endp
  161.  
  162. comparestrings proc near ; compares DS:SI & ES:DI and increments SI & DI
  163.  ; does for CX bytes sets carry flag
  164. cstr:
  165. repe cmpsb
  166. ret
  167. comparestrings endp
  168.  
  169. PUBLIC _READFONT
  170.  
  171. _readfont proc near ; designed for FAR pointers
  172. push bp
  173. mov bp,sp
  174. push ds
  175. push es
  176. push si
  177. push di
  178. call cmpegafalse
  179. jne rf1
  180. jmp norf
  181. numberofentries db 0
  182. i dw 0
  183. j dw 0
  184. k dw 0
  185. begchar dw 0
  186. endchar dw 0
  187. rf1:
  188. ;***************************** Switch this to "LEA SI,PARAMA" under small
  189. ;***************************** or tiny models.
  190. lds si,parama
  191. mov di,seg fontheader
  192. mov es,di
  193. mov di,offset fontheader
  194. mov cx,7
  195. call comparestrings
  196. je goon1
  197. jmp norf
  198. goon1:
  199. xor ax,ax
  200. lodsb
  201. push ax
  202. call _setscanlines
  203. pop ax
  204. lodsb
  205. mov linesperchar,al
  206. cmp al,16
  207. jb goon2
  208. jmp norf
  209. goon2:
  210. call setlinesperchar
  211. lodsb
  212. mov numberofentries,al
  213. mov i,0
  214. f2:
  215. lodsb
  216. xor ah,ah
  217. mov begchar,ax
  218. lodsb
  219. mov endchar,ax
  220.  
  221. mov ax,begchar
  222. mov j,ax
  223. f1:
  224. call _sequencefonts
  225. mov di,0a000h
  226. mov es,di
  227. mov bx,j
  228. mov di,bx
  229. mov cl,5
  230. shl di,cl
  231. mov cl,linesperchar
  232. inc cl
  233. xor ch,ch
  234. shr cl,1
  235. rep movsw
  236. call _desequencefonts
  237. inc j
  238. mov ax,endchar
  239. cmp j,ax
  240. jbe f1
  241. inc i
  242. mov al,numberofentries
  243. xor ah,ah
  244. cmp i,ax
  245. jbe f2
  246. norf:
  247. pop di
  248. pop si
  249. pop es
  250. pop ds
  251. pop bp
  252. ret
  253. _readfont endp
  254.  
  255. PUBLIC _READSCREEN
  256.  
  257. _readscreen proc near ; FAR pointer must be passed on
  258. push bp
  259. mov bp,sp
  260. push ds
  261. push es
  262. push si
  263. push di
  264. jmp rs1
  265. xy db 0 
  266. x1 db 1
  267. y1 db 1
  268. x2 db 80
  269. y2 db 25
  270. rs1:
  271. ;*************************************** Under small or tiny memory models,
  272. ;********************** switch to LEA SI,parama
  273. lds si,parama
  274. lodsb
  275. mov x1,al
  276. lodsb
  277. mov y1,al
  278. lodsb
  279. mov x2,al
  280. lodsb
  281. mov y2,al
  282. mov al,y1
  283. mov xy,al
  284. r1:
  285. mov cl,x2
  286. inc cl
  287. mov ch,x1
  288. sub cl,ch
  289. xor ch,ch
  290. shl cx,1
  291. mov di,vseg
  292. mov es,di
  293. mov al,xy
  294. dec al
  295. mov ah,0
  296. mov bl,80
  297. mul bl
  298. mov bl,x1
  299. dec bl
  300. xor bh,bh
  301. add bx,ax
  302. shl bx,1
  303. mov di,bx
  304. r2:
  305. lodsb
  306. stosb
  307. loop r2
  308. inc xy
  309. mov al,y2
  310. cmp xy,al
  311. jbe r1
  312. pop di
  313. pop si
  314. pop es
  315. pop ds
  316. pop bp
  317. ret 
  318. _readscreen endp
  319.  
  320. EGAGrfx proc near ; index in al , value in ah
  321. push dx
  322. mov dx,03ceh
  323. out dx,al
  324. inc dx
  325. mov al,ah
  326. out dx,al
  327. pop dx
  328. ret
  329. EGAgrfx endp
  330.  
  331. detEGA proc near
  332. mov vedone,true
  333. jmp dega
  334. testmask db 1
  335. BIOSbyte db 0
  336. dega:
  337. xor ax,ax
  338. mov es,ax
  339. mov vseg,0b800h
  340. mov bx,0410h
  341. mov al,es:[bx]
  342. and al,48
  343. cmp al,48
  344. jne deg2
  345. mov vseg,0b000h
  346. deg2:
  347. mov bx,0487h
  348. mov al,es:[bx]
  349. mov biosbyte,al
  350. mov ah,012h
  351. mov bx,0ff10h
  352. int 010h
  353. mov al,biosbyte
  354. and al,060h
  355. mov cl,5
  356. shr al,cl
  357. cmp bl,al
  358. je degcont
  359. cmp bh,0ffh
  360. jne degcont
  361. mov ega,false
  362. jmp degend
  363. degcont:
  364. mov ah,testmask
  365. mov al,8
  366. call EGAGrfx
  367. mov dx,03ceh
  368. mov al,8
  369. out dx,al
  370. mov vga,false
  371. mov dx,03cfh
  372. in al,dx
  373. cmp al,testmask
  374. jne eg1
  375. mov vga,true
  376. eg1:
  377. mov ax,0ff08h
  378. call egagrfx
  379. mov EGA,TRUE
  380. degend:
  381. ret
  382. detega endp
  383.  
  384. PUBLIC _SAVEFONTS
  385.  
  386. _savefonts proc near ; pass on FAR pointer 8192 bytes,
  387. push bp
  388. mov bp,sp
  389. push ds
  390. push es
  391. push si
  392. push di
  393. ;****************************Under small or tiny memory models, switch this
  394. ;**** to PUSH DS <cr> POP ES <cr> LEA DI,parama
  395. les di,parama
  396. call _sequencefonts
  397. mov si,0a000h
  398. mov ds,si
  399. xor si,si
  400. mov cx,4096
  401. rep movsw
  402. call _desequencefonts
  403. pop di
  404. pop si
  405. pop es
  406. pop ds
  407. pop bp
  408. ret
  409. _savefonts endp
  410.  
  411. PUBLIC _RESTOREFONTS
  412.  
  413. _restorefonts proc near ; pass on FAR pointer - 8192 bytes req.
  414. push bp
  415. mov bp,sp
  416. push ds
  417. push es
  418. push si
  419. push di
  420. ;**************************************Under small or tiny memory models, 
  421. ;*******switch to LEA SI,parama 
  422. lds si,parama
  423. call _sequencefonts
  424. mov di,0a000h
  425. mov es,di
  426. xor di,di
  427. mov cx,4096
  428. rep movsw
  429. call _desequencefonts
  430. pop di
  431. pop si
  432. pop es
  433. pop ds
  434. pop bp
  435. ret
  436. _restorefonts endp
  437.  
  438. PUBLIC _RESETFONTS
  439.  
  440. _resetfonts proc near
  441. push ax
  442. mov ax,083h
  443. int 010h
  444. mov al,2
  445. push ax
  446. call _setscanlines
  447. pop ax
  448. pop ax
  449. ret
  450. _resetfonts endp 
  451.  
  452. _CODE ENDS
  453. END
  454.